/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

$("#submituser").click(function () {
    var account = $("#myname").val();
    var datastr = "name=" + account;
    $.ajax({
        type: "post",
        url: "/../../controller/systemset/pmanagecontroller.php",
        data: datastr,
        success: function (e) {
            var result = eval("("+e+")");
            if (result.code == 0) {
                $("#close1").trigger("click");
                alert(result.msg+"  Your password is :"+account+"HJ");
            }
            
        }
    });
});
$(".btn-sd").click(function(){
    var cont = 1;
    var userid = $(this).data("id");
    var datastr = "cont="+cont+"&userid="+userid;
    $.ajax({
        type: "post",
        url: "/../../controller/systemset/usercontroller.php",
        data: datastr,
        success: function (e) {
            var result = eval("("+e+")");
            //$("#userlist"+userid).css("background-color","#666");
            //$("#userlist"+userid).css("color","#fff");
            alert(result.msg);
        }
    });
});
$(".btn-rt").click(function(){
    var cont = 2;
    var userid = $(this).data("id");
    var datastr = "cont="+cont+"&userid="+userid;
    $.ajax({
        type: "post",
        url: "/../../controller/systemset/usercontroller.php",
        data: datastr,
        success: function (e) {
            var result = eval("("+e+")");
            alert(result.msg);
        }
    });
});
$(".btn-gp").click(function(){
    var userid = $(this).data("id");
    $("#myuserid").val(userid);
});
$("#submitgroup").click(function(){
    var userid = $("#myuserid").val();
    var group = $("#checkgroup").val();
    var datastr = "cont=3&userid="+userid+"&group="+group;
    $.ajax({
        type: "post",
        url: "/../../controller/systemset/usercontroller.php",
        data: datastr,
        success: function (e) {
            var result = eval("("+e+")");
            alert(result.msg);
            $("#close2").trigger("click");
            if(result.code == 0){
                $("#group"+userid).html(result.gname);
            }
        }
    });
});
$("#allsubmitgroup").click(function(){
    var userid = $("#alluserid").val();
    var group = $("#allcheckgroup").val();
    var datastr = "cont=4&userid="+userid+"&group="+group;
    console.log(datastr);
    $.ajax({
        type: "post",
        url: "/../../controller/systemset/usercontroller.php",
        data: datastr,
        success: function (e) {
            var result = eval("("+e+")");
            console.log(result.msg);
            $("#close3").trigger("click");
            if(result.code == 0){
                layer.msg('操作成功', {
                    time: 2000, //2s后自动关闭
                    btn: ['OK']
                });
                location.reload();
            }else{
                layer.msg('操作失败,请刷新重试', {
                    time: 2000, //2s后自动关闭
                    btn: ['OK']
                });
            }
        }
    });
});

function closeall(ids){
    var datastr = "cont=5&userid="+ids;
    $.ajax({
        type: "post",
        url: "/../../controller/systemset/usercontroller.php",
        data: datastr,
        success: function (e) {
            var result = eval("("+e+")");
            console.log(e);
            if(result.code == 0){
                layer.msg('操作成功', {
                    time: 2000, //2s后自动关闭
                    btn: ['OK']
                });
            }else{
                layer.msg('操作失败,请刷新重试', {
                    time: 2000, //2s后自动关闭
                    btn: ['OK']
                });
            }
        }
    });
}
